You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Because regex are inherently bad at matching nested structures and I had fun in digging into grammar and especially pegjs (https://pegjs.org/), I wrote a grammar to perform the type rewrites. I also made a branch (#12), but I don't know if this should be merged because it would introduce a new syntax that might be difficult to maintain if not known and a new dependency.
The parser approach has 2 big advantages: It can easily handle nested structures and it can throw errors if it finds expressions that it should be able to parse, but some type is missing.
Nevertheless I used this grammar to check the output of our regular expression and found several issues. I created a new regex that does not produce any false positives and only misses a handful of rewrites in the whole code base.
Examples for expressions it can not handle are multiline types and some strangely nested types.
Also I found some types that where annotated like this: {module:ol/ImageState} which I don't know if they are correct. I would interpret these as the default export? I did not find something definitive in the jsdoc documentation.
@simonseyock Thanks for your work on this. I think the nested ones you listed above fail because they are multi-line comments. Maybe putting them on a single line would make them work? And the last one you mentioned has an invalid type (module:ol/PluggableMap~FrameState).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes openlayers/openlayers#10075
Because regex are inherently bad at matching nested structures and I had fun in digging into grammar and especially pegjs (https://pegjs.org/), I wrote a grammar to perform the type rewrites. I also made a branch (#12), but I don't know if this should be merged because it would introduce a new syntax that might be difficult to maintain if not known and a new dependency.
The parser approach has 2 big advantages: It can easily handle nested structures and it can throw errors if it finds expressions that it should be able to parse, but some type is missing.
Nevertheless I used this grammar to check the output of our regular expression and found several issues. I created a new regex that does not produce any false positives and only misses a handful of rewrites in the whole code base.
Examples for expressions it can not handle are multiline types and some strangely nested types.
I also found some more incorrect annotations in the codebase, that I fix in PR on the main repository.